#include "musicplayer.h"

#include <QApplication>
#include <QSharedMemory>
#include <QMessageBox>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    //实现单例应用程序
    QSharedMemory sharedMemory("MusicPlayer");
    //第一次运行程序sharedMemory.attach()失败,还未创建空间,后续运行进入if
    if(sharedMemory.attach())
    {
        QMessageBox::information(nullptr, "MusicPlayer提示", "MusicPlayer已经运行...");
        return 0;
    }

    //创建空间
    sharedMemory.create(1);

    MusicPlayer w;
    w.show();
    return a.exec();
}
